$(function () {
  let layer = layui.layer;
  let form = layui.form;
  $('#addForm').on('submit', function (e) {
    e.preventDefault();
    let data = $(this).serialize();
    //邮箱正则表达式
    form.verify({
      email: [/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/],
    });
    $.ajax({
      url: 'admin/users',
      type: 'POST',
      data,
      success: function (res) {
        console.log(res);
        if (res.status !== 0) {
          return layer.msg(res.message);
        }
        layer.msg(res.message);
        $('#addForm')[0].reset();
      },
    });
  });
});
